import Vue from 'vue'
import Router from 'vue-router'
import Index from './views/Index/index'
import Login from './views/Login/login'
import Registe from './views/Registe/registe'
import Account_password from './views/Account_password/account_password'
import Address_match from './views/Address_match/address_match'
import File_training from './views/File_training/file_training'
import Match_record from './views/Match_record/match_record'
Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      redirect: '/index'
    },
    {
      path: '/login',
      component: Login,
      name: 'Login'
    },
    {
      path: '/registe',
      component: Registe,
      name: 'Registe'
    },
    {
      path: '/index',
      name: 'Index',
      component: Index,
      redirect: '/address_match',
      children: [{
        path: '/account_password',
        component: Account_password,
        name: 'Account_password'
      },
      {
        path: '/address_match',
        component: Address_match,
        name: 'Address_match'
      },
      {
        path: '/file_training',
        component: File_training,
        name: 'File_training'
      },
      {
        path: '/match_record',
        component: Match_record,
        name: 'Match_record'
      },
      ]
    },
  ]
})

// 解决地址重复点击报错
const VueRouterPush = Router.prototype.push
Router.prototype.push = function push(to) {
  return VueRouterPush.call(this, to).catch(err => err)
}